﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Orange.Lib.Effective
{
    class Property
    {
        //属性的访问和方法相近 也可以是virtual 或 abstract
        private int myVar;

        public virtual int MyProperty
        {
            get { return myVar; }
            set { myVar = value; }
        }

        private int myVar2;

        public int MyProperty2
        {
            get { return myVar2; }
            set
            {
                CheckValue(myVar2);
                myVar2 = value;
                CheckValue(value);
            }
        }

        //Conditional使用
        [Conditional("DEBUG")]
        private void CheckValue(int val)
        {
            Trace.WriteLine("MyProperty2 is " + val);
        }
    }
}
